﻿using HCQ2_IBLL;
using HCQ2_Model;
using HCQ2_Model.APPModel.ParamModel;
using HCQ2_Model.VR.Params;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HCQ2_BLL
{
    public partial class T_VRScoreBLL: IT_VRScoreBLL
    {
        //******************************************pc*********************************************
        /// <summary>
        ///  获取个人成绩列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<VRScoreModel> GetOnLineList(ExperRecordModel param)
        {
            List<T_VRScore> list = new List<T_VRScore>();
            if (param.userId > 0)
                list = DBSession.IT_VRScoreDAL.Select(s => s.user_id == param.userId);
            else
                list = DBSession.IT_VRScoreDAL.Select(s => true);
            //用户名
            if (!string.IsNullOrEmpty(param.userName))
                list = list.Where(s => s.user_name.Contains(param.userName))?.ToList();
            //体验作品
            if (!string.IsNullOrEmpty(param.fileName))
                list = list.Where(s => s.file_name.Contains(param.fileName))?.ToList();
            //体验项目
            if (!string.IsNullOrEmpty(param.folderName))
                list = list.Where(s => s.folder_name.Contains(param.folderName))?.ToList();
            return list?.Select(s => s.ToPOCO())?.ToList();
        }

        //******************************************接口*******************************************
        /// <summary>
        ///  获取个人成绩列表
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userId">用户id</param>
        /// <returns></returns>
        public List<VRScoreModel> GetScoreListByUser(QueryRecordModel model,int userId)
        {
            List<T_VRScore> list = DBSession.IT_VRScoreDAL.Select(s => s.user_id.Equals(userId));
            if (list == null || list.Count <= 0)
                return null;
            if (model.file_id > 0)
                list = list.Where(s => s.file_id.Equals(model.file_id))?.ToList();
            if (!string.IsNullOrEmpty(model.folder_name))
                return list.Where(s => s.folder_name.Equals(model.folder_name))?.OrderBy(s => s.file_id).OrderBy(s => s.folder_name)?.Select(s => s.ToPOCO())?.ToList();
            return list?.OrderBy(s => s.file_id).OrderBy(s => s.folder_name)?.Select(s => s.ToPOCO())?.ToList();
        }
    }
}
